|
|
Hey Guys!
I want to check if a certain pigment is already defined and otherwise
define it. Normally that would be no problem, #ifndef does the job.
Unfortunately, I create my pigments dynamically within the SDL code.
Every pigment gets a number. The pigment's name would be
Parse_String(concat("Pigment",str(Number,0,0)))
but this does not work with #indef. The following code reports: "Parse
Error: Expexted ')', '(' found instead". The error occurs right after
"Parse_String" in the code:
<code>
#include "strings.inc"
#local Number = 34;
#local PigmentName = concat("Pigment",str(Number,0,0));
#ifndef(Parse_String(PigmentName))
#debug "no pigment defined, yet\n"
#end
</code>
I understand this from the parser's point of view - normaly, opening
brackets inside #ifndef() do not make sense, as identifiers aren't
allowed to contain brackets. In the case of Parse_String(), however,
it makes sense.
I see no reason to rewrite the parser because of this, but I'd like to
know if there is another possibility to check if an identifier from
which I got only the name as a string is already declared.
BTW, declaring such an identifier is possible: while
<code>
#declare Parse_String(PigmentName) = pigment { rgb<1,0,0> }
</code>
gives an error,
<code>
Parse_String(concat("#declare ",PigmentName)) = pigment { rgb<1,0,0> }
</code>
works perfectly.
Thanks in advance,
Florian
--
//=================[web: http://www.torfbold.com]==================\\
#local a=-5;#while(a<5)sphere{<sin(a*pi)*5a*10pow(a,5)*.01>sin(a*a*a*
.1)+1pigment{rgb 9*z}}#local a=a+.01;#end camera{look_at-y*10location
<8,-3,-8>*10}// [www.povray.org] [www.imp.org] [www.irtc.org]
Post a reply to this message
|
|